/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			pglnpattscale.h
  \date			Aug 2012
  \author		TNick

  \brief		Contains the definition for PgLnPattScale class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __PGLNPATTSCALE_INC__
#define __PGLNPATTSCALE_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<cpg/logic/pgcharacteristic.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

class	QDomElement;

namespace	cpg		{

class	CpgDoc;
class	PgCtx;

/**
*	@brief	manages the interactions with the scale of a pattern
*/
class PgLnPattScale		: public PgCharacteristic			{
	BBM_TRACK( PgLnPattScale );

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */


public:


	/**
	*	@brief	special values that mean something different than actual value
	*/
	enum	Id		{

		/* special codes */
		BYLAYER = PgCharacteristic::BYLAYER,
		BYBLOCK = PgCharacteristic::BYBLOCK,

		/* predefined codes */
		SCALE_1 = -101

	};


	/**
	*	@brief	the container for the list of line pattern (in a document, for example)
	*/
	typedef	QList<Id>			List;


	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:


	/**
	*	@brief	actual scale
	*/
	qreal			scale_;


	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:


	/**
	*	@brief	constructor
	*/
	PgLnPattScale			( CpgDoc * doc );


	/**
	*	@brief	destructor
	*/
	~PgLnPattScale			( void );


	/**
	*	@brief	report scale
	*/
	inline qreal			scale			( void )
	{ return scale_; }


	/**
	*	@brief	change scale
	*/
	inline void				setScale		( qreal new_val )
	{ scale_ = new_val; }


	/**
	*	@brief	clone this characteristic in target ocument
	*/
	PgLnPattScale *			clone			( CpgDoc * destin, int & idx );





	/* ******************************************************************* */
	/** @name 	Management methods                                         */
	/* ******************************************************************* */
	///@{


	/**
	*	@brief	tell if the id is inside allowed range
	*/
	static bool			isIdValid			( CpgDoc * doc, int id );


	/**
	*	@brief	get the scale for a code / explicit scale
	*/
	static qreal		explicitScale		(
			PgCtx *				ctx,
			qreal				id
			);


	/**
	*	@brief	save a scale as a XML attribute for provided element
	*/
	static void			asXML				(
			PgCtx *				ctx,
			qreal				id,
			QDomElement &		dest
			);


	/**
	*	@brief	copies a color from source document to target document
	*
	*	@return	the id to be used in destination document
	*/
	static int				copy			(
			CpgDoc *				source,
			CpgDoc *				destin,
			int					value
			);


	///@}
	/* ******************************************************************* */



	/* ******************************************************************* */
	/** @name 	String related nethods                                     */
	/* ******************************************************************* */
	///@{


protected:


	/**
	*	@brief	get the name that coresponds to given id
	*/
	static QString			nameForId		( Id id );


	/**
	*	@brief	get the names and coresponding id for all codes
	*/
	static void				nameAndId		(
			QStringList &			name_list,
			QList<int> &			id_list
			);


public:


	/**
	*	@brief	get the string that represents this pattern
	*/
	static QString			asString		( CpgDoc * doc, int id );


	///@}
	/* ******************************************************************* */



	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class PgLnPattScale	*/

/*  CLASS    =============================================================== */
//
//
//
//

}	//	namespace	cpg

#endif // __PGLNPATTSCALE_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
